/**
 * @param {string} s
 * @return {boolean}
 */
 var repeatedSubstringPattern = function(s) {
    const getNext = (needle)=>{
      let next = []
      let j = 0
      next.push(j)
      for(let i = 1;i < needle.length;i++){
        while(j > 0 && needle[i] !== needle[j]){
          j = next[j - 1]
        }
        if(needle[i] === needle[j]){
          j++
        }
        next.push(j)
      }
      return next
    }
    let next = getNext(s)
    console.log(next);
    if(next[next.length-1] !== 0 && s.length % (s.length - next[next.length - 1]) === 0){
      return true
    }
    return false
};
console.log(repeatedSubstringPattern('abcabcabcabc'));